
<?php include './application/views/top.php'; ?>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/My97DatePicker/WdatePicker.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<?php
		$sex = $v['sex'];
		$cardType = $v['cardType'];
	?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
		<div class="cont">
        <?php if($user['real_status'] == 1){ ?>
			<div class="tishi">您已经通过了实名认证，如要修改请跟客服联系。</div>
            <div class="clear h20"></div>
			<dl>
				<dt>用户名：</dt>
                <dd><?php echo $user['username']; ?></dd>
			</dl>
			<dl>
				<dt>真实姓名：</dt>
                <dd><?php echo strdisplay($user['realname'], 1); ?></dd>
			</dl>
			<dl>
				<dt>性别：</dt>
                <dd><?php echo $user['sex']==1?'男':'女'; ?></dd>
			</dl>
			<dl>
				<dt>民族：</dt>
                <dd><?php echo isset($minzu[$user['nation']])?$minzu[$user['nation']]:'-'; ?></dd>
			</dl>
			<dl>
				<dt>出生日期：</dt>
                <dd><?php echo date('Y-m-d',$user['birthday']); ?></dd>
			</dl>
			<dl>
				<dt>证件类别：</dt>
                <dd><?php echo $cardType[$user['card_type']]; ?></dd>
			</dl>
			<dl>
				<dt>证件号码：</dt>
                <dd><?php echo substr($user['card_id'], 0,strlen($user['card_id'])-4).'****'; ?></dd>
			</dl>
			<dl>
				<dt>籍贯：</dt>
                <dd><?php echo $area[$user['province']],' ',$area[$user['city']],' ',$area[$user['area']]; ?></dd>
			</dl>
			<dl>
				<dt>居住地：</dt>
                <dd><?php echo @$area[$user_info['province']],' ',@$area[$user_info['city']],' ',@$area[$user_info['area']]; ?></dd>
			</dl>
        <?php }else{ ?>
        	<iframe name="iframe" id="iframe" style="display:none;"></iframe>
            <form action="" id="realname_form"  enctype="multipart/form-data" method="post" onsubmit="return checkForm();" >
            <input type="hidden" name="act" value="submit">
			<dl>
				<dt>真实姓名：</dt>
                <dd><input class="input" type="text" id="realname" name="realname" value="<?php echo $user['realname']; ?>"></dd>
			</dl>
			<dl>
				<dt>性别：</dt>
                <dd>
				<input type="radio" value="1" name="sex" <?php echo $user['sex']!=2 ?"checked='checked'":''; ?>>男
				<input type="radio" value="2" name="sex" <?php echo $user['sex']==2 ?"checked='checked'":''; ?>>女
                </dd>
			</dl>
			<dl>
				<dt>民族：</dt>
                <dd>
				<select class="pubinput" id="nation" name="nation">
					<?php foreach ($minzu as $key => $val) {?>
					<option value="<?php echo $key;?>" <?php if($user['nation']==$key) echo "selected='selected'"; ?>><?php echo $val;?></option>
					<?php }?>
				</select>
                </dd>
			</dl>
			<dl>
				<dt>出生日期：</dt>
                <dd><input class="input" type="text" value="<?php echo $user['birthday']?date('Y-m-d',$user['birthday']):''; ?>" id="birthday" name="birthday" onfocus="WdatePicker()" readonly></dd>
			</dl>
			<dl>
				<dt>证件类别：</dt>
                <dd>
				<select class="pubinput" id="card_type" name="card_type">
					<?php foreach ($cardType as $k => $v) {?>
					<option value="<?php echo $k;?>" <?php if($user['card_type']==$k) echo "selected='selected'"; ?>><?php echo $v;?></option>
					<?php }?>
				</select>
                </dd>
			</dl>
			<dl>
				<dt>证件号码：</dt>
                <dd><input class="input" type="text" value="<?php echo $user['card_id']; ?>" id="card_id" name="card_id"></dd>
			</dl>
			<dl>
				<dt>籍贯：</dt>
                <dd>
				<select class="pubinput" id="province" name="province" onchange="getChild(this.value,'','city');"><option value="">请选择</option></select>
				<select class="pubinput" id="city" name="city" onchange="getChild(this.value,'','area');"><option value="">请选择</option></select>
				<select class="pubinput" id="area" name="area"><option value="">请选择</option></select>
                </dd>
			</dl>
			<dl>
				<dt>现居住地：</dt>
                <dd>
				<select class="pubinput" name="province2" id="province2" onchange="getChild(this.value,'','city2');"><option value="">请选择</option></select>
				<select class="pubinput" name="city2" id="city2" onchange="getChild(this.value,'','area2');"><option value="">请选择</option></select>
				<select class="pubinput" name="area2" id="area2"><option value="">请选择</option></select>
                </dd>
			</dl>
			<dl class="line">
				<dt>证件正面上传：</dt>
                <dd><input type="file" class="input_border" size="20" name="card_pic1" id="card_pic1"><span>请上传图片大小为500KB以内，尺寸不超过1500像素*2000像素的图片</span></dd>
			</dl>
			<dl class="line">
				<dt>证件反面上传：</dt>
                <dd><input type="file" class="input_border" size="20" name="card_pic2" id="card_pic2"><span>建议使用QQ截图保存后的图片进行实名认证申请</span></dd>
			</dl>
            <div class="cb"><input class="button" type="submit" value="确认提交" /></div>
            </form>
            <script type="text/javascript" charset="utf-8"></script>
								<script>
                                    <?php if($user['real_status'] != 1){ ?>
                                    $(document).ready(function(){
                                        getChild(0,'<?php echo isset($user['province'])?$user['province']:''; ?>','province');
                                        <?php if(isset($user['city']) && $user['city']){ ?>
                                        getChild('<?php echo $user['province']; ?>','<?php echo $user['city']; ?>','city');
                                        <?php } ?>

                                        <?php if(isset($user['area']) && $user['area']){ ?>
                                        getChild('<?php echo $user['city']; ?>','<?php echo $user['area']; ?>','area');
                                        <?php } ?>
                                    });

                                    $(document).ready(function(){
                                        getChild(0,'<?php echo isset($user_info['province'])?$user_info['province']:''; ?>','province2');
                                        <?php if(isset($user_info['city']) && $user_info['city']){ ?>
                                        getChild('<?php echo $user_info['province']; ?>','<?php echo $user_info['city']; ?>','city2');
                                        <?php } ?>

                                        <?php if(isset($user_info['area']) && $user_info['area']){ ?>
                                        getChild('<?php echo $user_info['city']; ?>','<?php echo $user_info['area']; ?>','area2');
                                        <?php } ?>
                                    });

                                    <?php } ?>
                                    function getChild(pid, selected,obj){
                                        $.ajax({
                                            type: "POST",
                                            url: "/area/get_option",
                                            data: "pid="+pid+"&selected="+selected,
                                            success: function(msg){
                                                $("#"+obj).html(msg);
                                            },
                                            dataType: "text"
                                        });
                                    }

                                    function realnameSubmit(){
                                        /*
                                         $('#dialog').dialog({
                                         modal:true,
                                         title:'系统提示',
                                         close: function() {
                                         },
                                         });
                                         $("#msg").html("正在提交请求，请稍候...");



                                         var options = {
                                         url : '',
                                         contentType:"multipart/form-data",
                                         beforeSubmit:  checkForm,
                                         data : { card_pic1: $("#card_pic1").val(),card_pic2: $("#card_pic2").val() },
                                         dataType: "json",
                                         type:"post",
                                         success : function(ret) {
                                         if(ret.msg==''){
                                         $('#dialog').dialog({
                                         modal:true,
                                         title:'系统提示',
                                         buttons:{"确定":function(){$(this).dialog("close");}}
                                         });
                                         $("#msg").html("操作成功，等待管理员审核");
                                         }else{
                                         $('#dialog').dialog({
                                         modal:true,
                                         title:'系统提示',
                                         buttons:{"确定":function(){$(this).dialog("close");}}
                                         });
                                         $("#msg").html(ret.msg);
                                         }
                                         }
                                         };
                                         $("#realname_form").ajaxSubmit(options);
                                         return false;
                                         */
                                    }

                                    function checkForm(){
                                        var err = '';
                                        if($('#realname').val()==''){
                                            err = '请填写真实姓名';
                                        }else if($('#nation').val()==''){
                                            err = '请选择名族';
                                        }else if($('#birthday').val()==''){
                                            err = '请填写生日';
                                        }else if($('#card_type').val()==''){
                                            err = '请选择证件类型';
                                        }else if($('#card_id').val()==''){
                                            err = '请填写证件号码';
                                        }else if($('#province').val()==''){
                                            err = '请填写完整的籍贯地址';
                                        }else if($('#city').val()==''){
                                            err = '请填写完整的籍贯地址';
                                        }else if($('#area').val()==''){
                                            err = '请填写完整的籍贯地址';
                                        }else if($('#province2').val()==''){
                                            err = '请填写完整的现居住地址';
                                        }else if($('#city2').val()==''){
                                            err = '请填写完整的现居住地址';
                                        }else if($('#area2').val()==''){
                                            err = '请填写完整的现居住地址';
                                        }else if(IsChinese($('#realname').val())==false){
                                            err = '请填写有效的真实姓名';
                                        }else if(IsDate($('#birthday').val())==false){
                                            err = '请填写有效的生日日期';
                                        }else if($('#card_type').val()==1 && isCardID($('#card_id').val())==false){
                                            err = '请填写有效的证件号码';
                                        }

                                        if(err==''){
                                            return true;
                                        }else{
                                            $('#dialog').dialog({
                                                modal:true, //蒙层（弹出会影响页面大小）
                                                title:'系统提示',
                                                buttons:{"确定":function(){$(this).dialog("close");}}
                                            });
                                            $("#msg").html(err);
                                            return false;
                                        }
                                    }


                                </script>
        <?php } ?>
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>